/*
 * 每回合会自动使用的技能。
 */
/*
	Buff的用法：
	需要在构造函数中传入持续的回合数，用useSkill来加buff。
	需要重载onUnlearn函数，当buff时间到消失的时候会自动调用。
	也可以重载use函数，在buff存在的时候每回合都会自动调用。
*/

#ifndef AI9_LOGIC_2017_AUTOMATIC_H
#define AI9_LOGIC_2017_AUTOMATIC_H

#include "skill.h"
#include <map>

class Automatic: public Skill{
public:
    Automatic() : Skill(){
        this->setName("Automatic");
        this->hidden = true;
    }
};

namespace skill {
    class DescendCoolDown : public Automatic {
    public:
        DescendCoolDown() : Automatic() {
            this->setName("DescendCoolDown");
            this->turn = TurnName::DescendCoolDownTurn;
        }

        virtual bool use(Game *g, const std::vector<std::string> &params) override;
    };
    class DeathCalulation: public Automatic {
    public:
        DeathCalulation(): Automatic() {
            this->setName("DeathCalulation");
            this->turn = TurnName::DeathCalculationTurn;
        }

        virtual bool use(Game *g, const std::vector<std::string> &params) override;
    };
	class Buff: public Automatic{
	public:
		int remaining;
        int stackable = false;
        std::string minor_id;
		Buff(int r, Entity* sender = nullptr);

        virtual bool onLearn(Game *g) override;

        Json::Value toJson() override;

        virtual bool use(Game *g, const std::vector<std::string> &params) override;
        virtual bool onMerge(Skill *orig);
	};
    class BuffHelper: public Automatic{
    public:
        std::map<std::string, Buff*> buffList;
        BuffHelper(Buff* buff): Automatic(){
            this->setName("BuffHelper");
            this->setName(buff->name);
            this->turn = buff->turn;
        }

        Json::Value toJson() override;

        bool use(Game *g, const std::vector<std::string> &params) override;
        void add(Buff* buff);
        void remove(std::string minor_id);
    };

}

#endif //AI9_LOGIC_2017_AUTOMATIC_H
